<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
 
class Rating extends CI_Controller {
 	     public function __construct()

       {

            parent::__construct();

		$this->load->helper("html");

		$this->load->helper("url");

		$this->load->helper('form');

		$this->load->helper('date');

		$this->load->model("rating_model");

		//$this->load->model("guest_comment_model");

		//$this->load->model("news_events_model");

		//$this->load->model("roomcottages_model");

		$this->load->helper(array('form', 'url'));

		$this->load->database();
 	}
 	//START ------------------dv---------------------

	function index()

	{

		$data['title']="Administrator Page";

		$data["list_ratings"] = $this->rating_model->get_all_rating();	

		$this->load->view('rating_list_view',$data);

	}
 	function view_rating()

	{

		$code = $this->uri->segment(3);

		$data["info"] = $this->rating_model->getrating_info($code);	

		$this->load->view('rating_vw_view',$data);

 	}
 	function add_rating()

	{

		//$data["driver_dv_data"] = $this->dv_model->add_view_driver_dv();

		$this->load->view('rating_add_view');

	}

	function p_add_rating()

	{
 		$this->load->database();			

		$rating =$_POST['txtrating'];

		$_sql="insert into rating(rating)";

		$_sql.="values('$rating')";

		$query = $this->db->query($_sql); 

	/*	$dv_id=$this->db->insert_id();

	 

		$_sql="insert into dv_contract(dv_id,contract_amount)";

		$_sql.="values($dv_id,$contract_amt)";

		$query = $this->db->query($_sql); */

			

		$data["list_ratings"] = $this->rating_model->get_all_rating();	

		$this->load->view('rating_list_view',$data);

							

	}
 	function edit_rating()
 	{

 	    $code = $this->uri->segment(3);

		$data["info"] = $this->rating_model->getrating_info($code);	

		$this->load->view('rating_edit_view',$data);

	}
 	function p_edit_rating()

	{

		$this->load->database();

		    $id= $_POST['hid_id'];

			$rating = $_POST['txtrating'];

			$query = $this->db->query("UPDATE rating SET 
 			 rating='$rating' where id=$id");

														  

		$data["list_ratings"] = $this->rating_model->get_all_rating();	

		$this->load->view('rating_list_view',$data);		

	}

	

	

	function delete_rating()

	{

		$this->load->database();		

		$code = $this->uri->segment(3);

		$query = $this->db->query("delete from profile where profile_id='$code'");

		

		$data["list_ratings"] = $this->rating_model->get_all_rating();	

		$this->load->view('rating_list_view',$data);

	}

	//END ------------------dv---------------------

	

	

	function logout()

	{

		

		//$this->load->library('session');

		//$this->session->sess_destroy();

		session_start();

		session_destroy();

		//echo $_SESSION['Administrator_log'];

		//unset($_SESSION['Administrator_log']);

		

			//$data["newsresult"] = $this->dv_model->dv_all_driver_dv();

			$this->load->view('admin_view');

	 

	}

 

}

?>